<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>文章添加--layui后台管理模板</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="../../css/font_eolqem241z66flxr.css" media="all"/>
    <script src="../../jquery-3.3.1/jquery-3.3.1.min.js"></script>
    <script src="../../jquery-3.3.1/jquery-3.3.1.js"></script>


    <script type="text/javascript" src="../../../tool/ajax.js"></script>
    <script>

    </script>
</head>
<body class="childrenBody">
<form class="layui-form" style="display: flex;flex-direction: column;align-content: center">
    <div class="layui-form-item">
        <label class="layui-form-label">客服微信号</label>
        <div class="layui-input-block">
            <input type="text" id="username" class="layui-input newsName" lay-verify="required"
                   >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">类型</label>
        <div class="layui-input-block">
            <input type="text" id="type" class="layui-input newsName" lay-verify="required"
                   placeholder="1普通客服,2高级客服"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^1-2-]+/,'');}).call(this)" onblur="this.v();" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <input type="text" id="code" class="layui-input newsName" lay-verify="required"
                   >
        </div>
    </div>


    <button
            type="button" align="center"  onclick="adduser()"  class="layui-btn layui-btn-normal layui-btn-radius" style="width:30%;margin: 0 auto;" >提交信息
    </button>


</form>
<script type="text/javascript" src="../../../layui-v2.2.6/layui/layui.js"></script>
</body>
<script>



    function adduser() {
        var username = document.getElementById("username").value;
        var code = document.getElementById("code").value;
        var type = document.getElementById("type").value;

        ajaxpost("system/service", {type:type,name: username, code: code}, function (data) {
            try {
                if (data.code == 200) {

                        parent.location.reload();

                } else {


                        parent.location.reload();

                }
            } catch (e) {
                layer.msg('添加失败', {
                    icon: 0,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function () {
                    parent.location.reload();
                });
            }
        })
    }


</script>
</html>